package club.easin.config;


import org.neo4j.ogm.session.SessionFactory;
import org.springframework.context.annotation.Bean;
import org.springframework.context.annotation.Configuration;
import org.springframework.data.neo4j.repository.config.EnableNeo4jRepositories;
import org.springframework.data.neo4j.transaction.Neo4jTransactionManager;
import org.springframework.transaction.annotation.EnableTransactionManagement;

@Configuration
@EnableNeo4jRepositories(basePackages="club.easin")
@EnableTransactionManagement
public class Neo4jConfig {
	
	@Bean
	public SessionFactory sessionFactory(){
		 org.neo4j.ogm.config.Configuration configuration = new org.neo4j.ogm.config.Configuration.Builder()
				 .uri("bolt://127.0.0.1:7687")
				 .credentials("neo4j", "123456")
				 .build();
		 
		 return new SessionFactory(configuration, "club.easin");

	}
	
	 @Bean
	 public Neo4jTransactionManager transactionManager() {

	      return new Neo4jTransactionManager(sessionFactory());

	   }
	

}
